package com.qfedu.openplateform.gateway.filter;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * 系统参数
 *
 * 真实的需要去 后台管理应用 去取，
 *
 * 现在我们写死要求前端必须传递
 *
 * appkey
 * cusid  这俩个必传 暂时不校验
 *
 *     如果没有传递 拦截
 *         有传递  放行
 *
 *
 */
public class SystemParamFilter implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        response.setContentType("application/json;charset=utf-8");

//        String apiname = request.getParameter("APINAME");
//        String parameter = request.getParameter("SYSTEMPARAMS:KEYS");
//        String appkey = request.getParameter("APPKEY");
//        String apicustomer = request.getParameter("APICUSTOMER");
//        String idempotents = request.getParameter("IDEMPOTENTS");
//        String token = request.getParameter("TOKEN");
        String appKey = request.getParameter("appKey");
        String cusId = request.getParameter("cusId");

        if (appKey.equals("ak") && cusId.equals("cd")) {
            return true;
        } else {
            response.getWriter().print("systemParameters Error");
            return false;
        }


    }
}
